//
//  LocalizedMenu.m
//  Statz
//
//  Created by Dave MacLachlan on 2007/12/27.
//  Copyright 2007 Google Inc. All rights reserved.
//

#import "LocalizedMenu.h"


@implementation LocalizedMenu
- (id)initWithTitle:(NSString *)aTitle {
  NSString *localizedTitle = NSLocalizedString(aTitle, @"initWithTitle");
  return [super initWithTitle:localizedTitle];
}

- (void)awakeFromNib {
  NSEnumerator *enumerator = [[self itemArray] objectEnumerator];
  NSMenuItem *item = nil;
  while ((item = [enumerator nextObject])) {
    NSString *title = [item title];
    NSString *localizedTitle = NSLocalizedString(title, "awakeFromNib");
    [item setTitle:localizedTitle];
  }
}

- (void)setTitle:(NSString *)aString {
  NSString *localizedTitle = NSLocalizedString(aString, @"setTitle");
  [super setTitle:localizedTitle];
}

- (id <NSMenuItem>)insertItemWithTitle:(NSString *)aString 
                                action:(SEL)aSelector 
                         keyEquivalent:(NSString *)charCode 
                               atIndex:(int)index {
  NSString *localizedTitle = NSLocalizedString(aString, @"insertItemTitle");
  return [super insertItemWithTitle:localizedTitle 
                             action:aSelector 
                      keyEquivalent:charCode 
                            atIndex:index];
}

- (id <NSMenuItem>)addItemWithTitle:(NSString *)aString 
                             action:(SEL)aSelector 
                      keyEquivalent:(NSString *)charCode {
  NSString *localizedTitle = NSLocalizedString(aString, @"addItemWithTitle");
  return [super addItemWithTitle:localizedTitle
                          action:aSelector
                   keyEquivalent:charCode];
}

@end
